package org.changchen.fgt.utils;

import java.util.HashMap;
import java.util.Map;

/**   
* @ClassName:  ApplicationContextUtil   
* @Description:上下文工具类   
* @author:     ChangChen 
* @date:       2024-02-26 15:39
* @Copyright:  2024 ChangChen. All rights reserved. 
*/
public class ApplicationContextUtil {

	
	private static final ThreadLocal<Map<String,Object>> context = new ThreadLocal<>();
	
	
	public static void set(String key, Object value) {
		Map<String,Object> map = context.get();
		if(map == null) {
			map = new HashMap<>();
		}
		map.put(key, value);
		context.set(map);
	}
	
	
	public static Object get(String key) {
		Map<String,Object> map = context.get();
		if(map == null) {
			return null;
		}
		return map.get(key);
	}
	
	
	public static void remove() {
		context.remove();
	}
	
	
	private ApplicationContextUtil() {}
	
	
}
